/** 
 * Description:商品推荐设置DAO
 * Date:2013-1-16
 * Author:Along	
*/
package com.community.shopping.dao;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.community.shopping.domain.IndexGroup;

public class IndexGroupDao extends HibernateDaoSupport{
	private Log log = LogFactory.getLog(IndexGroupDao.class);  
	

	public void save(IndexGroup indexGroup){
		getHibernateTemplate().saveOrUpdate(indexGroup);	
		log.debug("-------保存一行indexGroup-------");
	}

	public void delete(IndexGroup indexGroup){		  
		getHibernateTemplate().delete(indexGroup);
		log.debug("---------删除一行indexGroup-------");
	}

	public List<IndexGroup> getIndexGroup(String sql){
		String finalsql="from IndexGroup where "+sql;
		return getHibernateTemplate().find(finalsql);
	}
	
	public IndexGroup getIndexGroup(Integer id){
		return getHibernateTemplate().load(IndexGroup.class, id);
	}
	
	public int getMaxSort(String sql)
	{
		Query   query   = this.getSession().createQuery("select max(sort) from IndexGroup where "+sql); 
		if(query.list().get(0)==null)
		{return 0;}
		int i=Integer.parseInt(query.list().get(0).toString());
		return i;
	}
	
	}
